home *** CD-ROM | disk | FTP | other *** search
- /*
- File: CMApplication.h
-
- Contains: Header for Color Matching aware applications
-
- Written by: Konstantin Othmer
-
- Copyright: © 1992-93 by Apple Computer, Inc., all rights reserved.
-
-
- */
-
-
- #ifndef __CMAPPLICATION__
- #define __CMAPPLICATION__
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <QuickDraw.h>
- #endif
-
- #ifndef __PRINTING__
- #include <Printing.h>
- #endif
-
-
- #define gestaltColorMatchingVersion 'cmtc'
-
- #define CMTrap 0xABEE
-
- /*
- ** PicComments
- */
- #define CMBeginProfile 220
- #define CMEndProfile 221
- #define CMEnableMatching 222
- #define CMDisableMatching 223
-
- /* Defines for fieldMask in profile search record */
- #define kMatchCMMType 0x00000001
- #define kMatchApplProfileVersion 0x00000002
- #define kMatchDataType 0x00000004
- #define kMatchDeviceType 0x00000008
- #define kMatchDeviceManufacturer 0x00000010
- #define kMatchDeviceModel 0x00000020
- #define kMatchDeviceAttributes 0x00000040
- #define kMatchFlags 0x00000080
- #define kMatchOptions 0x00000100
- #define kMatchWhite 0x00000200
- #define kMatchBlack 0x00000400
-
-
- /* Profile Header version */
- #define kCMApplProfileVersion 0x0100
-
- /* Data types */
- enum {
- rgbData = 'RGB ',
- cmykData = 'CMYK',
- grayData = 'GRAY',
- xyzData = 'XYZ '
- };
-
- /* Device types */
- enum {
- monitorDevice = 'mntr',
- scannerDevice = 'scnr',
- printerDevice = 'prtr',
- qdSystemDevice = 'sys ',
- qdGDevice = 'gdev'
- };
-
- /* Profile flags */
- enum {
- CMNativeMatchingPreferred = 0x00000001, /* Default to native not preferred */
- CMTurnOffCache = 0x00000002 /* Default to turn on CMM cache */
- };
-
- typedef long CMMatchFlag;
-
- /* Profile options */
- enum {
- CMPerceptualMatch = 0x0000, /* Default. For photographic images */
- CMColorimetricMatch = 0x0001, /* Exact matching when possible */
- CMSaturationMatch = 0x0002 /* For solid colors */
- };
-
- typedef long CMMatchOption;
-
-
- typedef long CMMatchRef;
-
- typedef long CWorld;
-
-
- /* ColorSync result codes */
- enum {
- CMNoError = 0,
- CMProfileError = -170,
- CMMethodError = -171,
- CMMemFullError = -172,
- CMUnimplementedError = -173,
- CMParamError = -174,
- CMMethodNotFound = -175, /* CMM not present */
- CMProfileNotFound = -176, /* Responder error */
- CMProfilesIdentical = -177, /* Profiles the same */
- CMCantConcatenateError = -178, /* Profile can't be concatenated */
- CMCantXYZ = -179, /* CMM cant handle XYZ space */
- CMCantDeleteProfile = -180, /* Responder error */
- CMUnsupportedDataType = -181, /* Responder error */
- CMNoCurrentProfile = -182 /* Responder error */
- };
-
- typedef long CMError;
-
-
- /*
- ** Types
- */
-
- struct XYZColor {
- unsigned short X; /* 1.15 bit unsigned fixed numbers */
- unsigned short Y;
- unsigned short Z;
- };
-
- typedef struct XYZColor XYZColor;
-
-
- struct CMYKColor {
- unsigned short cyan;
- unsigned short magenta;
- unsigned short yellow;
- unsigned short black;
- };
-
- typedef struct CMYKColor CMYKColor;
-
-
- union CMColor {
- RGBColor rgb;
- XYZColor xyz;
- CMYKColor cmyk;
- };
-
- typedef union CMColor CMColor, *CMColorList;
-
-
- typedef long *CMGamutResult; /* Pointer to bit array */
-
-
- struct CMHeader {
- unsigned long size; /* This is the total size of the Profile including custom data */
- OSType CMMType; /* Corresponding CMM */
- unsigned long applProfileVersion; /* Version of CMProfile format */
- OSType dataType; /* rgbData, etc. */
- OSType deviceType; /* monitorDevice, etc. */
- OSType deviceManufacturer; /* Registered with DTS */
- unsigned long deviceModel; /* Specific to Manufacturer */
- unsigned long deviceAttributes[2]; /* Attributes like paper, ink, etc. */
- unsigned long profileNameOffset; /* Offset to profile name from top of data */
- unsigned long customDataOffset; /* Offset to custom data from top of data */
- CMMatchFlag flags;
- CMMatchOption options;
- XYZColor white;
- XYZColor black;
- };
-
- typedef struct CMHeader CMHeader;
-
-
- struct CMProfileSearchRecord {
- CMHeader header;
- unsigned long fieldMask;
- unsigned long reserved[2];
- };
-
- typedef struct CMProfileSearchRecord CMProfileSearchRecord, **CMProfileSearchRecordHandle;
-
-
- struct CMProfileChromaticities {
- XYZColor red;
- XYZColor green;
- XYZColor blue;
- XYZColor cyan;
- XYZColor magenta;
- XYZColor yellow;
- };
-
- typedef struct CMProfileChromaticities CMProfileChromaticities;
-
-
- typedef unsigned short CMResponseData;
-
-
- struct IString {
- ScriptCode theScript;
- Str63 theString;
- };
-
- typedef struct IString IString, *IStringPtr, **IStringHandle;
-
-
- enum {
- grayResponse = 0,
- redResponse,
- greenResponse,
- blueResponse,
- cyanResponse,
- magentaResponse,
- yellowResponse,
- ucrResponse,
- bgResponse,
- onePlusLastResponse
- };
-
- typedef long responseColor;
-
- struct CMProfileResponse {
- unsigned short counts[onePlusLastResponse];
- CMResponseData data[1]; /* Variable size */
- };
-
- typedef struct CMProfileResponse CMProfileResponse;
-
-
- struct CMProfile {
- CMHeader header;
- CMProfileChromaticities profile;
- CMProfileResponse response; /* Variable size */
- IString profileName; /* Variable size */
- char customData[1]; /* Optional variable length custom CMM data */
- };
-
- typedef struct CMProfile CMProfile, *CMProfilePtr, **CMProfileHandle;
-
-
- typedef pascal Boolean (*PixMapCallBackProcPtr)( long progress, long refCon );
-
- /*
- ** Printing Stuff that will be moved later
- */
-
- enum {
- enableColorMatchingOp =12,
- registerProfileOp =13
- };
-
- /* PrGeneral parameter blocks */
-
- struct TEnableColorMatchingBlk
- {
- short iOpCode;
- short iError;
- long lReserved;
- THPrint hPrint;
- Boolean fEnableIt;
- };
-
- typedef struct TEnableColorMatchingBlk TEnableColorMatchingBlk;
-
-
- struct TRegisterProfileBlk
- {
- short iOpCode;
- short iError;
- long lReserved;
- THPrint hPrint;
- Boolean fRegisterIt;
- };
-
- typedef struct TRegisterProfileBlk TRegisterProfileBlk;
-
-
- /*
- ** High Level Calls
- */
-
- #define CMCall( selector, argsize ) {0x203c,argsize,selector,CMTrap}
-
- pascal CMError BeginMatching( CMProfileHandle src, CMProfileHandle dst, CMMatchRef *myRef )
- = CMCall( 10, 0x000C );
-
- pascal void EndMatching( CMMatchRef myRef )
- = CMCall( 11, 0x0004 );
-
- pascal CMError GetProfile( long deviceType, long refNum, CMProfileHandle aProfile, CMProfileHandle *returnedProfile )
- = CMCall( 5, 0x0010 );
-
- pascal CMError SetProfile( long deviceType, long refNum, CMProfileHandle newProfile )
- = CMCall( 6, 0x000c );
-
- pascal CMError SetProfileDescription( long deviceType, long refNum, long deviceData, CMProfileHandle hProfile )
- = CMCall( 16, 0x0010 );
-
- pascal CMError GetColorSyncFolderSpec(short vRefNum, Boolean createFolder, short *foundVRefNum, long *foundDirID)
- = CMCall( 17, 0x000c );
-
- pascal CMError GetIndexedProfile( long deviceType, long refNum, CMProfileSearchRecordHandle search,
- CMProfileHandle *returnProfile, long *index )
- = CMCall( 18, 0x0014 );
-
- pascal CMError DeleteDeviceProfile( long deviceType, long refNum, CMProfileHandle deleteMe )
- = CMCall( 19, 0x000C );
-
- /*
- ** Data interchange routines
- */
- pascal CMError UseProfile( CMProfileHandle profile )
- = CMCall( 8, 0x0004 );
-
- pascal void DrawMatchedPicture( PicHandle myPicture, CMProfileHandle dst, Rect *myRect )
- = CMCall( 9, 0x000C );
-
- pascal void EnableMatching( Boolean enableIt )
- = CMCall( 13, 0x0002 );
-
- /*
- ** Profile concatenation
- */
- pascal CMError ConcatenateProfiles( CMProfileHandle thru, CMProfileHandle dst, CMProfileHandle *newDst )
- = CMCall( 12, 0x000C );
-
- /*
- ** Profile manipulation routines
- */
- pascal void GetProfileName( CMProfileHandle myProfile, IString *IStringResult )
- = CMCall( 14, 0x0008 );
-
- pascal long GetProfileAdditionalDataOffset( CMProfileHandle myProfile )
- = CMCall( 15, 0x0004 );
-
- /*
- ** Low level color calculation routines
- */
- pascal CMError CWNewColorWorld( CWorld *myCWorld, CMProfileHandle src, CMProfileHandle dst )
- = CMCall( 0, 0x000C );
-
- pascal void CWDisposeColorWorld( CWorld myCWorld )
- = CMCall( 1, 0x0004 );
-
- pascal CMError CWMatchColors( CWorld myCWorld, CMColorList myColors, long count )
- = CMCall( 2, 0x000c );
-
- pascal CMError CWCheckColors( CWorld myCWorld, CMColorList myColors, long count, CMGamutResult result )
- = CMCall( 3, 0x0010 );
-
- pascal CMError CWMatchPixMap( CWorld myCWorld, PixMap *myPixMap, PixMapCallBackProcPtr progressProc, long refCon )
- = CMCall( 4, 0x0010 );
-
- pascal CMError CWCheckPixMap( CWorld myCWorld, PixMap *myPixMap, PixMapCallBackProcPtr progressProc, long refCon, BitMap *resultBitMap )
- = CMCall( 7, 0x0014 );
-
- #endif